extends Area2D

var delta_x
var delta_y
var speed = 300

# var sprite_size = Vector2(72, 85)
var screen_size

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	screen_size = get_viewport_rect().size
	delta_x = -1 if randi_range(1, 2) == 1 else 1
	delta_y = -1 if randi_range(1, 2) == 1 else 1
	
	position = Vector2(300, 300)


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	position.x = position.x + speed * delta * delta_x
	if position.x > screen_size.x - 25 or position.x < 25:
		delta_x = -delta_x
	position.y = position.y + speed * delta * delta_y
	if position.y > screen_size.y - 25 or position.y < 25:
		delta_y = -delta_y
